package com.baizhi.controller;


import com.baizhi.entity.AttrGroup;
import com.baizhi.service.IAttrGroupService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 属性分组 前端控制器
 * </p>
 *
 * @author haiyu
 * @since 2021-09-16
 */
@RestController
@RequestMapping("/attrGroup")
public class AttrGroupController {

    @Autowired
    private IAttrGroupService ags;

    //根据商品类别的id查询该类别下面所有的属性分组信息
@GetMapping("/selectById/{cateId}")
    public List<AttrGroup> selectById(@PathVariable("cateId") Integer cateId){
        QueryWrapper<AttrGroup> wrapper=new QueryWrapper<>();
        wrapper.eq("category_id",cateId);
        List<AttrGroup> list = ags.list(wrapper);
        return list;
    }
    @PostMapping("/addGroup")
    public void addGroup(@RequestBody AttrGroup group){
    ags.save(group);
    }
}

